﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinScriptEngine.Parses
{
    /// <summary>
    /// 单例类
    /// </summary>
    /// <typeparam name="Class">派生类</typeparam>
    class SingletonObject<Class> where Class : new() 
    {
        static readonly Class @object ;
        public SingletonObject()
        {
            if (@object != null)
                throw new NotImplementedException($"Class '{typeof(Class).Name}' is singleton!");
        }

        static SingletonObject()
        {
            @object = new();
        }

        public static Class GetInstance()
        {
            return @object;
        }
    }
}
